package myJs

import assets._
import myJs.Implicits._
import myJs.cps.{PureInputCp, Style}
import myJs.myPkg.{MyFetch, NProgress, Outlet, ReactRouterDOM}
import org.scalajs.dom.document
import org.scalajs.dom.window.localStorage
import slinky.core.FunctionalComponent
import slinky.core.annotations.react
import slinky.core.facade.Hooks._
import slinky.core.facade.ReactElement
import slinky.web.html._

import scala.concurrent.ExecutionContext.Implicits.global
import scala.scalajs.js

/**
 * Created by yz on 22/4/2022
 */
@react object MainCp {

  case class Props(title: String, children: ReactElement)


  private val css = List(
    assetsCss.Layer,
    assetsCss.Sweetalert,
    assetsCss.BootstrapMin,
//    assetsCss.Bootstrap4Min,
    assetsCss.BootstrapThemeMin,
    assetsCss.Doc,
    assetsCss.BootstrapDatepicker3,
//    assetsCss.FontAwesomeMin,
    assetsCss.FontAwesomeFree,
    assetsCss.Components,
    assetsCss.BootstrapTable,
    assetsCss.Nprogress,
    assetsCss.TableFilter,
    assetsCss.Select2Min,
    assetsCss.BootstrapMultiselectMin,
  )

  private val css1=assetsCss.Bootstrap4Toggle
  private val css2=assetsCss.My

  val component = FunctionalComponent[Props] { props =>

    useEffect(() => {
      startLoad
      document.title = s"${props.title}-GepLiver"
      loadComplete
    }, List()
    )

    div(className := "container",
      HeaderCp(),
      props.children,
      FooterCp(),
    )


  }

  def startLoad = {
    NProgress.start()
  }

  def loadComplete = {
    NProgress.done()
  }

}
